package com.easyssh.framework.service.impl;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

import com.easyssh.framework.orm.hibernate.HibernateAbstractDao;
import com.easyssh.framework.service.IBaseService;

public abstract class BaseServiceImpl<T, D extends HibernateAbstractDao<T,PK>, PK extends Serializable> implements IBaseService<T, PK> {
	public abstract D getEntityDao();

	public T find(PK id) {
		return getEntityDao().find(id);
	}
	
	public T get(PK id) {
		return getEntityDao().get(id);
	}

	public List<T> findAll() {
		return getEntityDao().findAll();
	}
	
	public void insert(T o){
		this.getEntityDao().insert(o);
	}
	
	public void update(T o){
		this.getEntityDao().update(o);
	}

	public void save(T o) {
		getEntityDao().save(o);
	}

	public void merge(T o) {
		getEntityDao().merge(o);
	}

	public void delete(T o) {
		getEntityDao().delete(o);
	}

	public void delete(PK id) {
		getEntityDao().delete(id);
	}
	
	public void delete(final Collection<T> entities) {
		getEntityDao().delete(entities);
	}
	
	public List<T> findByIds(List<PK> ids) {
		return getEntityDao().findByIds(ids);
	}
	
	public List<T> findByIds(PK[] ids) {
		return getEntityDao().findByIds(ids);
	}
}
